{% extends 'cms/cms-base.html' %}
{% block title %}类目管理{% endblock %}
{% block main %}
    <blockquote class="layui-elem-quote"><h2>类目管理</h2></blockquote>
    <!-- list  -->
    <div class="layui-row">
        <table class="layui-table" lay-filter="list" id="list">
        </table>
    </div>
{% endblock %}
{% block footer %}
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="add"><i class="layui-icon">&#xe624; 新类目</i>
            </button>
        </div>
    </script>
    <script>
        function renderTable() {
            return table.render({
                elem: '#list'
                , page: false
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , url: api+'types/'
                , where:{
                    token:token
                }
                , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                , cols: [[
                    {field: 'id', title: 'ID'}
                    , {field: 'name', title: '标题'}
                    , {
                        field: 'post_nums', title: '数量', templet: function (d) {
                            return d.post_nums || 0
                        }
                    }
                ]]
            });
        }
        $(function () {
            // 渲染表格
            var tableIns = renderTable()
            //监听头部工具
            table.on('toolbar(list)', function (obj) {
                // var checkStatus = table.checkStatus(obj.config);
                switch (obj.event) {
                    case 'add':
                        var index = layer.open({
                            title: '添加新类目'
                            , type: 2
                            , anim: 5
                            , area: ['300px']
                            , content: '/cms/types/add/'
                        });
                        break;
                }
            });
        })
    </script>

{% endblock %}
